<template>
	<view class="content">
		<view class="header">
			<view class="img">
				<image src="../../../static/logo.png" mode=""></image>
			</view>
			<view class="" style="margin: 0 auto;">{{type}}</view>
			<view class="">{{edition}}</view>
		</view>
		<view class="" v-if="list.length>0" style="background-color: rgba(216, 216, 216, 0);">
			<view class="list" v-for="(item,index) in list" @click="oper(item)">
				<view class="">{{item.type}}</view>
				<image src="../../../static/icon/set-code/nav-back.png" mode=""></image>
			</view>
		</view>
		<renew ref="renew" 
		@renew="renew" 
		@cancel="cancel" 
		:bol="show"
		:renewData="renewData"
		style="position:fixed;top:0;z-index:999" v-if="show"></renew>
	</view>
</template>

<script>
	import renew from '@/components/common/renew/renew.vue'
	import uniPopup from '@/components/uni-ui/uni-popup/uni-popup.vue';
	import {
		update,
		compareVersion,
		downWgt,
		installWgt
	} from '@/components/common/renew/renew.js'
	import {
		myMessage,
		selectNurseDetai,
		getNewVersion
	} from '@/apis/nurse/index.js'
	export default {
		data() {
			return {
				bol: false,
				renewData: {},
				type: '护士小鹿 (护士端)',
				edition: '',
				list: [{
						type: '检查更新',
					},
					{
						type: '服务须知',
					},
					{
						type: '隐私政策',
					},
				],
				show:false //是否展示
			}
		},
		onShow() {
			this.getNow()
		},
		methods: {
			async oper(item) {
				let type = item.type
				switch (type) {
					case '检查更新':
						let _this = this
						let res = await update()
						console.log(res,'版本获取............')
						if (res.data.success) {
							if(res.data.object){
								this.renewData = res.data.object
								this.show = true
								console.log(res,this.show)
							}else{
								// console.log('最新版本是-------------------');
								// 当前是最新版本---暂无更新
								  plus.nativeUI.toast('当前已是最新版本')
							}
						} else {
							 plus.nativeUI.toast('当前已是最新版本')
						}
						break;
					case '服务须知':
						console.log(type);
						uni.navigateTo({
							url: '../nurse-need/nurse-need'
						});
						break;
					case '隐私政策':
						console.log(type);
						uni.navigateTo({
							url: '../hide/hide'
						});
						break;
				}
			},
			//获取当前版本号
			getNow() {
				let _this = this
				// #ifdef APP-PLUS
				plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
					console.log(JSON.stringify(wgtinfo));
					console.log(wgtinfo.version, '当前版本号'); //应用版本号
					_this.edition = wgtinfo.version
				})
				// #endif

			},
			renew() {
				this.$refs.renew.renew()
				this.show = false
			},
			cancel() {
				this.show = false
				this.$refs.renew.cancel()
			},

		},
		components: {
			uniPopup,
			renew,
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background-color: #F7F7F7;
		height: 100vh;
	}

	.header {
		width: 100%;
		height: 444rpx;
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(0, 0, 0, 0.87);
		text-align: center;
		padding-top: 88rpx;
		box-sizing: border-box;
	}

	.img {
		width: 180rpx;
		height: 180rpx;
		// background-color: #C6F7F6;
		margin: 0 auto;
		margin-bottom: 8rpx;

		image {
			width: 180rpx;
			height: 180rpx;
		}
	}

	.list {
		width: 698rpx;
		height: 108rpx;
		border-bottom: 1rpx #D8D8D8 solid;
		margin: 0 auto;
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
	}

	.list image {
		width: 48rpx;
		height: 48rpx;
	}
</style>
